var kevi=function(t){"use strict";function e(t,e,n,r,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void n(t)}c.done?e(u):Promise.resolve(u).then(r,o)}function n(t){return function(){var n=this,r=arguments;return new Promise((function(o,i){var a=t.apply(n,r);function c(t){e(a,o,i,c,u,"next",t)}function u(t){e(a,o,i,c,u,"throw",t)}c(void 0)}))}}function r(t,e,n){return e=i(e),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,a()?Reflect.construct(e,n||[],i(t).constructor):e.apply(t,n))}function o(t,e){for(var n=0;n=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(u&&s){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),L(n),w}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;L(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:P(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),w}},e}function u(t,e){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},u(t,e)}function s(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function l(t){var e="function"==typeof Map?new Map:void 0;return l=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return function(t,e,n){if(a())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var o=new(t.bind.apply(t,r));return n&&u(o,n.prototype),o}(t,arguments,i(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),u(n,t)},l(t)}var d=window.location.href.includes("index.html")||window.location.href.includes(".local.kevi"),f=d?"http://api.local.kevi.io/client/":"https://api.kevi.io/client/",p=d?"http://api.local.kevi.io/":"https://api.kevi.io/",h={token:null,projectId:"",clientId:""},v=function(t){function e(t){var n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(n=r(this,e,["HTTP error! status: ".concat(t.status)])).response=t,Object.setPrototypeOf(n,e.prototype),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&u(t,e)}(e,t),n=e,i&&o(n.prototype,i),a&&o(n,a),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,i,a}(l(Error));function g(){return g=n(c().mark((function t(e,n){var r,o,i,a,u=arguments;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=u.length>2&&void 0!==u[2]?u[2]:{},o={"Content-Type":"application/json","X-Project-ID":h.projectId},i={method:e.toUpperCase(),headers:o},"get"!==e.toLowerCase()&&(i.body=JSON.stringify(r)),t.next=6,fetch(f+n,i);case 6:if((a=t.sent).ok){t.next=9;break}throw new Error("HTTP error! status: ".concat(a.status));case 9:return t.abrupt("return",a.json());case 10:case"end":return t.stop()}}),t)}))),g.apply(this,arguments)}function w(t,e){return m.apply(this,arguments)}function m(){return m=n(c().mark((function t(e,n){var r,o,i,a,u=arguments;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=u.length>2&&void 0!==u[2]?u[2]:{},o={"Content-Type":"application/json"},h.token&&(o.Authorization="Bearer ".concat(h.token)),h.clientId&&(o["X-Client-ID"]=h.clientId),h.projectId&&(o["X-Project-ID"]=h.projectId),i={method:e.toUpperCase(),headers:o},"get"!==e.toLowerCase()&&(i.body=JSON.stringify(r)),t.next=9,fetch(f+n,i);case 9:if((a=t.sent).ok){t.next=12;break}throw new v(a);case 12:return t.abrupt("return",a.json());case 13:case"end":return t.stop()}}),t)}))),m.apply(this,arguments)}function y(t,e){return b.apply(this,arguments)}function b(){return b=n(c().mark((function t(e,n){var r,o,i,a=arguments;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=a.length>2&&void 0!==a[2]?a[2]:{},!h.clientId&&!h.token){t.next=5;break}return t.abrupt("return",w(e,n,r));case 5:window.localStorage&&(o=window.localStorage.getItem("kevi-requests"),(i=o?JSON.parse(o):[]).push({method:e,url:n,data:r,time:(new Date).getTime()}),window.localStorage.setItem("kevi-requests",JSON.stringify(i)));case 6:case"end":return t.stop()}}),t)}))),b.apply(this,arguments)}function k(){return(k=n(c().mark((function t(){var e,n,r;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!window.localStorage){t.next=16;break}e=window.localStorage.getItem("kevi-requests"),n=e?JSON.parse(e):[];case 3:if(!(n.length>0)){t.next=15;break}return r=n.shift(),t.prev=5,t.next=8,w(r.method,r.url,r.data);case 8:t.next=13;break;case 10:t.prev=10,t.t0=t.catch(5),console.error(t.t0);case 13:t.next=3;break;case 15:window.localStorage.setItem("kevi-requests",JSON.stringify(n));case 16:case"end":return t.stop()}}),t,null,[[5,10]])})))).apply(this,arguments)}for(var x,I=[],S=0;S<256;++S)I.push((S+256).toString(16).slice(1));var _=new Uint8Array(16);var O={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function E(t,e,n){var r,o,i,a;if(O.randomUUID&&!e&&!t)return O.randomUUID();var c=null!==(r=null!==(o=(t=t||{}).random)&&void 0!==o?o:null===(i=(a=t).rng)||void 0===i?void 0:i.call(a))&&void 0!==r?r:function(){if(!x){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");x=crypto.getRandomValues.bind(crypto)}return x(_)}();if(c.length<16)throw new Error("Random bytes length must be >= 16");if(c[6]=15&c[6]|64,c[8]=63&c[8]|128,e){if((n=n||0)<0||n+16>e.length)throw new RangeError("UUID byte range ".concat(n,":").concat(n+15," is out of buffer bounds"));for(var u=0;u<16;++u)e[n+u]=c[u];return e}return function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(I[t[e+0]]+I[t[e+1]]+I[t[e+2]]+I[t[e+3]]+"-"+I[t[e+4]]+I[t[e+5]]+"-"+I[t[e+6]]+I[t[e+7]]+"-"+I[t[e+8]]+I[t[e+9]]+"-"+I[t[e+10]]+I[t[e+11]]+I[t[e+12]]+I[t[e+13]]+I[t[e+14]]+I[t[e+15]]).toLowerCase()}(c)}var j="kevi-quotation",q="kevi-quotation-id";function L(){if("undefined"!=typeof window&&window.localStorage){var t=window.localStorage.getItem(j);if(t)try{return JSON.parse(t)}catch(t){return console.error("Error parsing stored quotation:",t),null}}return null}function T(t){var e;if("undefined"!=typeof window&&window.localStorage){if(!t.expire_date){var n=new Date;n.setMinutes(n.getMinutes()+30),t.expire_date=n.toISOString().slice(0,19).replace("T"," ")}t.id=null!==(e=t.id)&&void 0!==e?e:E(),window.localStorage.setItem(j,JSON.stringify(t)),t.id&&window.localStorage.setItem(q,t.id.toString())}}function P(){if("undefined"!=typeof window&&window.localStorage){var t=window.localStorage.getItem("kevi-client");if(t)try{var e=JSON.parse(t);if(e.id)return{id:e.id}}catch(t){console.error("Error parsing client data:",t)}}return{}}function N(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"draft",e=new Date,n=new Date(e);n.setMinutes(n.getMinutes()+30);var r=n.toLocaleString("pt-BR",{timeZone:"America/Sao_Paulo"}),o=e.toLocaleString("pt-BR",{timeZone:"America/Sao_Paulo"});return{status:t,value:0,date:o.slice(0,19).replace("T"," "),expire_date:r,client:P(),items:[],products:[],created_at:o}}function C(t){var e=t.reduce((function(t,e){return t+(e.price||0)*(e.quantity||1)}),0);return Math.round(e)}function D(){return!!h.clientId||!!h.token}function R(t){return U.apply(this,arguments)}function U(){return(U=n(c().mark((function t(e){var n,r,o,i;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=(null===(n=e.products)||void 0===n?void 0:n.map((function(t){return{id:t.product_external_id||t.name.replace(/\s+/g,"_").toLowerCase(),name:t.name,unitPrice:Math.round(t.price||0),quantity:t.quantity,category:t.category}})))||[],o={id:e.id,value:Math.round(e.value),date:e.date,expire_date:e.expire_date,status:e.status,branchId:e.branchId,fields:e.fields,items:r,orders:e.orders,client:e.client},t.prev=2,t.next=5,w("post","quotation/upsert",o);case 5:if(!((i=t.sent)&&i.response&&i.response.quotation&&i.response.quotation.length>0)){t.next=9;break}return t.abrupt("return",i);case 9:return t.abrupt("return",i);case 12:throw t.prev=12,t.t0=t.catch(2),console.error("Error upserting quotation to backend:",t.t0),t.t0;case 16:case"end":return t.stop()}}),t,null,[[2,12]])})))).apply(this,arguments)}function A(t){return M.apply(this,arguments)}function M(){return(M=n(c().mark((function t(e){var n,r,o,i,a,u;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((n=L())||(n=N()),n.products||(n.products=[]),r=Object.assign(Object.assign({},e),{price:Math.round(e.price||0),quantity:e.quantity||1}),-1!==(o=n.products.findIndex((function(t){var e=t.name===r.name,n=Math.round(t.price||0)===Math.round(r.price||0),o=t.product_external_id&&r.product_external_id&&t.product_external_id===r.product_external_id;return r.product_external_id?o:e&&n})))?(i=n.products[o],a=i.quantity||1,i.quantity=a+r.quantity):n.products.push(r),n.value=C(n.products),n.client=P(),T(n),!D()){t.next=22;break}return t.prev=10,t.next=13,R(n);case 13:return(u=t.sent)&&u.external_quote_id&&(n.id=u.external_quote_id,T(n)),t.abrupt("return",{status:"success",quotationId:n.id,productId:null==u?void 0:u.productId});case 18:throw t.prev=18,t.t0=t.catch(10),console.error("Error sending quotation to backend:",t.t0),t.t0;case 22:return t.abrupt("return",{status:"success",message:"Product added to quotation (stored locally)"});case 23:case"end":return t.stop()}}),t,null,[[10,18]])})))).apply(this,arguments)}function F(t){return Q.apply(this,arguments)}function Q(){return(Q=n(c().mark((function t(e){var n,r;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((n=L())?n.status=e:n=N(e),n.client=P(),T(n),!D()){t.next=17;break}return t.prev=5,t.next=8,R(n);case 8:return(r=t.sent)&&r.external_quote_id&&(n.id=r.external_quote_id,T(n)),t.abrupt("return",{status:"success",quotationId:n.id});case 13:throw t.prev=13,t.t0=t.catch(5),console.error("Error sending quotation to backend:",t.t0),t.t0;case 17:return t.abrupt("return",{status:"success",message:"Status updated (stored locally)"});case 18:case"end":return t.stop()}}),t,null,[[5,13]])})))).apply(this,arguments)}function z(t){return J.apply(this,arguments)}function J(){return(J=n(c().mark((function t(e){var n,r,o;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=L(),r=e||(null==n?void 0:n.id),"undefined"!=typeof window&&window.localStorage&&(window.localStorage.removeItem(j),window.localStorage.removeItem(q)),r&&"null"!==r){t.next=5;break}return t.abrupt("return",{status:"success",message:"Local quotation data cleared"});case 5:if(!D()){t.next=17;break}return t.prev=6,t.next=9,w("delete","quotation/".concat(r));case 9:return o=t.sent,t.abrupt("return",o);case 13:throw t.prev=13,t.t0=t.catch(6),console.error("Error removing quote from backend:",t.t0),t.t0;case 17:return t.abrupt("return",{status:"success",message:"Quotation cleared locally (will be deleted when identified/authenticated)"});case 18:case"end":return t.stop()}}),t,null,[[6,13]])})))).apply(this,arguments)}function B(t){return G.apply(this,arguments)}function G(){return(G=n(c().mark((function t(e){var n,r;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((n=L())||(n=N()),(n=Object.assign(Object.assign(Object.assign({},n),e),{client:P(),products:e.products||n.products||[],items:e.items||n.items||[]})).products&&n.products.length>0&&(n.value=C(n.products)),T(n),!D()){t.next=18;break}return t.prev=6,t.next=9,R(n);case 9:return(r=t.sent)&&r.external_quote_id&&(n.id=r.external_quote_id,T(n)),t.abrupt("return",{status:"success",quotationId:n.id,response:r});case 14:throw t.prev=14,t.t0=t.catch(6),console.error("Error updating quotation to backend:",t.t0),t.t0;case 18:return t.abrupt("return",{status:"success",message:"Quotation updated locally",quotation:n});case 19:case"end":return t.stop()}}),t,null,[[6,14]])})))).apply(this,arguments)}function H(t,e,n){return V.apply(this,arguments)}function V(){return V=n(c().mark((function t(e,r,o){var i,a,u,s,l,d=arguments;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return l=function(){clearTimeout(a),a=setTimeout(u,12e4)},s=function(){return(s=n(c().mark((function t(){var n,a,u;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,fetch(e,{method:r,headers:i.headers,body:i.body});case 3:if((n=t.sent).ok){t.next=6;break}throw new Error("Request failed with status ".concat(n.status));case 6:return t.next=8,n.json();case 8:return a=t.sent,u=o(a),t.abrupt("return",B(u));case 13:t.prev=13,t.t0=t.catch(0),console.error("Error in track quotation:",t.t0);case 16:case"end":return t.stop()}}),t,null,[[0,13]])})))).apply(this,arguments)},u=function(){return s.apply(this,arguments)},i=d.length>3&&void 0!==d[3]?d[3]:{},t.next=6,u();case 6:window.addEventListener("load",u),window.addEventListener("click",u),["click","mousemove","keydown","scroll","touchstart"].forEach((function(t){return window.addEventListener(t,l)})),l();case 10:case"end":return t.stop()}}),t)}))),V.apply(this,arguments)}function X(){return(X=n(c().mark((function t(){var e,n;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=L()){t.next=3;break}return t.abrupt("return");case 3:if(D()){t.next=5;break}return t.abrupt("return");case 5:if(e.products&&0!==e.products.length){t.next=7;break}return t.abrupt("return");case 7:return t.prev=7,e.client=P(),T(e),t.next=12,R(e);case 12:(n=t.sent)&&n.external_quote_id&&(e.id=n.external_quote_id,T(e)),t.next=19;break;case 16:t.prev=16,t.t0=t.catch(7),console.error("❌ Error auto-processing stored quotation:",t.t0);case 19:case"end":return t.stop()}}),t,null,[[7,16]])})))).apply(this,arguments)}function Y(){P().id&&setTimeout((function(){(function(){return X.apply(this,arguments)})().catch((function(t){console.error("❌ Error in auto-processing quotation:",t)}))}),100)}function Z(){window.localStorage.removeItem("kevi-quotation"),window.localStorage.removeItem("kevi-quotation-id")}t.client={id:"",phone:"",email:"",firstName:"",lastName:"",external_id:""},t.isIdentified=!1,t.isAuthenticated=!1;var K=[],W=[],$=function(e){return K.push(e),t.isIdentified&&e(),function(){var t=K.indexOf(e);-1!==t&&K.splice(t,1)}},tt=function(e){return W.push(e),t.isAuthenticated&&e(),function(){var t=W.indexOf(e);-1!==t&&W.splice(t,1)}},et=function(){K.forEach((function(t){return t()}))},nt=function(){W.forEach((function(t){return t()}))},rt=function(e){var n=t.isIdentified!==e&&e;t.isIdentified=e,n&&et()},ot=function(e){var n=t.isAuthenticated!==e&&e;t.isAuthenticated=e,e&&rt(!0),n&&nt()};function it(){return w("get","profile").then((function(t){console.log("profile",t),t.client?(at({id:t.client.id,phone:t.client.whatsapp,email:t.client.email,firstName:t.client.first_name,lastName:t.client.last_name,external_id:t.client.external_id}),ot(!0)):ot(!1)})).catch((function(){ot(!1)}))}function at(e){window.localStorage&&window.localStorage.setItem("kevi-client",JSON.stringify(e)),t.client=Object.assign(Object.assign({},t.client),e),e.id&&(h.clientId=e.id);var n=t.isIdentified;return t.client.id&&rt(!0),!n&&t.client.id&&Y(),function(){return k.apply(this,arguments)}()}function ct(t){return ut.apply(this,arguments)}function ut(){return(ut=n(c().mark((function t(e){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return h.token=e,window.localStorage&&window.localStorage.setItem("kevi-token",e),t.next=4,it();case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function st(t){return w("get","login/auth-code?code=".concat(t)).then((function(t){t.token&&ct(t.token)})).catch((function(){}))}function lt(){return w("get","login/send-sms?phone=".concat(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"","&placeId=").concat(h.projectId)).then((function(t){at({id:t.client.id})})).catch((function(){}))}function dt(t){return w("get","login/auth?code=".concat(t,"&clientId=").concat(h.clientId)).then((function(t){t.token&&ct(t.token)})).catch((function(){}))}function ft(){return w("get","dashboard")}function pt(t,e){return w("post","unsubscribe/".concat(t),{unsubscribeType:e,clientId:h.clientId})}function ht(e){var n=e.phone,r=e.email,o=e.firstName,i=e.lastName,a=e.external_id;return function(t,e){return g.apply(this,arguments)}("post","identify",{external_id:a,phone:n,email:r,firstName:o,lastName:i}).then((function(e){e.clientId&&at({id:e.clientId,phone:n||t.client.phone,email:r||t.client.email,firstName:o||t.client.firstName,lastName:i||t.client.lastName,external_id:a||t.client.external_id});return t.client}))}function vt(){return w("get","dashboard")}function gt(t){return w("post","use-reward/".concat(t))}var wt,mt,yt={all:[]};function bt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"all";yt[e]||(yt[e]=[]),yt[e].push(t)}function kt(t){y("post","custom-event",{event:t,created_at:(new Date).toISOString()})}mt={"kevi-form-resize":function(t){var e=Array.from(document.getElementsByTagName("iframe")).find((function(e){return e.contentWindow===t.source}));e&&(e.style.height=t.data.height)},"kevi-form-submitted":(wt=n(c().mark((function e(n){var r,o,i,a,u,s;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.client.id===(null===(i=null===(o=null===(r=n.data)||void 0===r?void 0:r.result)||void 0===o?void 0:o.client)||void 0===i?void 0:i.id)){e.next=3;break}return e.next=3,at({id:null===(s=null===(u=null===(a=n.data)||void 0===a?void 0:a.result)||void 0===u?void 0:u.client)||void 0===s?void 0:s.id});case 3:yt.all.length>0&&yt.all.forEach((function(t){return t(n)})),n.data&&n.data.formId&&yt[n.data.formId]&&yt[n.data.formId].forEach((function(t){return t(n)}));case 5:case"end":return e.stop()}}),e)}))),function(t){return wt.apply(this,arguments)})},window.addEventListener("message",(function(t){t.data&&t.data.type&&mt[t.data.type]&&mt[t.data.type](t)}));var xt={};function It(t){return St.apply(this,arguments)}function St(){return St=n(c().mark((function e(n){var r,o,i,a,u=arguments;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=u.length>1&&void 0!==u[1]?u[1]:0,o=u.length>2&&void 0!==u[2]?u[2]:500,i=u.length>3&&void 0!==u[3]?u[3]:0,t.isIdentified){e.next=5;break}return e.abrupt("return",[]);case 5:return e.next=7,w("get","smart-insertions/".concat(n));case 7:if(a=e.sent){e.next=14;break}if(!(i>=r)){e.next=11;break}return e.abrupt("return",[]);case 11:return e.next=13,new Promise((function(t){return setTimeout(t,o)}));case 13:return e.abrupt("return",It(n,r,o,i+1));case 14:return e.abrupt("return",a.filter((function(t){if(window.localStorage){if(window.localStorage.getItem("hideInsertionFromMe_"+t.id))return!1;var e=window.localStorage.getItem("hideInsertion_"+t.id);if(e&&(new Date).getTime()=20)return void(xt[t].searching=!1)}})).catch((function(e){console.error("Error fetching smart insertions for id ".concat(t,":"),e)})).finally((function(){var e=xt[t];if(e&&e.searching){e.timeout&&clearTimeout(e.timeout);var n=e.poolCount?300*Math.pow(1.3,e.poolCount):3e3;e.timeout=setTimeout((function(){return _t(t)}),n)}}))}function Ot(e,n){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];t.isIdentified?(xt[e]?(xt[e].callback=n,xt[e].singleRun=r,xt[e].poolCount=1,xt[e].searching=!0):xt[e]={insertions:[],latestId:"",callback:n,timeout:null,singleRun:r,poolCount:1,searching:!0},_t(e)):$((function(){Ot(e,n,r)}))}function Et(t,e){return e=encodeURIComponent(e),"".concat(p,"smart-insertions/").concat(t,"/html?field=").concat(e)}function jt(t){window.localStorage&&window.localStorage.setItem("hideInsertionFromMe_"+t,"true")}function qt(t,e){var n=(new Date).getTime()+60*e*60*1e3;window.localStorage&&window.localStorage.setItem("hideInsertion_"+t,n.toString())}function Lt(t){window.sessionStorage&&window.sessionStorage.setItem("hideInsertionSession_"+t,"true")}var Tt=[],Pt=function(t){Tt.push(t)},Nt=function(){Tt.forEach((function(t){return t()}))};t.initialized=!1;var Ct=function(){};function Dt(e){Ct=e,t.initialized&&Ct()}function Rt(t){return Ut.apply(this,arguments)}function Ut(){return Ut=n(c().mark((function e(n){var r,o,i,a,u=arguments;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=u.length>1&&void 0!==u[1]?u[1]:"",h.projectId=n,r&&ct(r),o=new URLSearchParams(window.location.search),!(i=o.get("ka"))){e.next=8;break}return e.next=8,st(i);case 8:(a=window.localStorage.getItem("kevi-client"))&&at(JSON.parse(a)),window.setTimeout((function(){if(!h.token&&window.localStorage){var e=window.localStorage.getItem("kevi-token");e&&ct(e)}t.initialized||(Nt(),Ct(),t.initialized=!0)}),500);case 11:case"end":return e.stop()}}),e)}))),Ut.apply(this,arguments)}function At(){var t=new URLSearchParams(window.location.search),e=t.get("gclid"),n=t.get("utm_source"),r=t.get("utm_medium"),o=t.get("utm_campaign");if(e||n||r||o){if(window.localStorage){var i=window.localStorage.getItem("kevi-last-campaign-track"),a=i?Number(i):0;if(a&&(new Date).getTime()-a<36e5)return;window.localStorage.setItem("kevi-last-campaign-track",(new Date).getTime().toString())}y("post","campaign-interaction",{channel:"SDK",gclid:e,utm_source:n,utm_medium:r,utm_campaign:o,created_at:(new Date).toISOString()})}}Pt((function(){At()}));var Mt=Object.freeze({__proto__:null,get client(){return t.client},get isIdentified(){return t.isIdentified},get isAuthenticated(){return t.isAuthenticated},onIdentify:$,onAuthenticate:tt,triggerIdentify:et,triggerAuthenticate:nt,fetchProfile:it,setClient:at,setToken:ct,shortCodeAuth:st,sendSmsOTP:lt,authenticateOTP:dt,getData:ft,unsubscribe:pt,identifyClient:ht,getBenefitsData:vt,useReward:gt,onFormSubmit:bt,trackEvent:kt,getSmartInsertions:It,getSmartInsertionHtmlUrl:Et,hideInsertion:jt,hideInsertionForHours:qt,hideInsertionForSession:Lt,onSmartInsertion:Ot,trackCampaignInteraction:At,addInitializer:Pt,get initialized(){return t.initialized},setInitializer:Dt,init:Rt,addProductToQuote:A,setQuoteStatus:F,removeQuote:z,clearQuote:Z,updateQuotation:B,trackQuotationChanges:H});return function(){if(window){var t=window.kevi&&window.kevi.q?window.kevi.q:[],e=Object.assign({},Mt);window.kevi=e,t.forEach((function(t){var e=t[0];"function"==typeof window.kevi[e]&&window.kevi[e].apply(window.kevi,t.slice(1))}))}}(),t.addInitializer=Pt,t.addProductToQuote=A,t.authenticateOTP=dt,t.clearQuote=Z,t.fetchProfile=it,t.getBenefitsData=vt,t.getData=ft,t.getSmartInsertionHtmlUrl=Et,t.getSmartInsertions=It,t.hideInsertion=jt,t.hideInsertionForHours=qt,t.hideInsertionForSession=Lt,t.identifyClient=ht,t.init=Rt,t.onAuthenticate=tt,t.onFormSubmit=bt,t.onIdentify=$,t.onSmartInsertion=Ot,t.removeQuote=z,t.sendSmsOTP=lt,t.setClient=at,t.setInitializer=Dt,t.setQuoteStatus=F,t.setToken=ct,t.shortCodeAuth=st,t.trackCampaignInteraction=At,t.trackEvent=kt,t.trackQuotationChanges=H,t.triggerAuthenticate=nt,t.triggerIdentify=et,t.unsubscribe=pt,t.updateQuotation=B,t.useReward=gt,Object.defineProperty(t,"__esModule",{value:!0}),t}({}); //# sourceMappingURL=kevi.bundle.js.map